package com.matt.controller;

import com.dotflat.fin.PO.WalletPO;
import com.dotflat.fin.domain.Wallet;
import com.dotflat.fin.service.WalletService;
import com.dotflat.rest.controller.RestfulBaseController;
import com.matt.commons.dto.sso.StaffDTO;
import com.matt.commons.exception.BusinessException;
import com.matt.commons.model.StatusResponse;
import com.matt.commons.page.PagerQuery;
import com.matt.domain.Clientele;
import com.matt.foundation.model.ErrorCode;
import com.matt.foundation.model.MemVerificationCache;
import com.matt.service.ClienteleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.Field;

import static com.matt.foundation.constant.CommonConstant.TICKET;

/**
 * @author ：Ron
 * @date ：Created in 11/5/2020 7:36 PM
 */
@RestController
@RequestMapping("/other_system/wallet")
@Api(tags = "其他系统 - 客户钱包")
public class OtherSystemWalletController {

    @Autowired
    protected WalletService baseService;

    @Autowired
    protected ClienteleService clienteleService;

    @Autowired
    public void setBaseService(WalletService service){
        this.baseService = service;
    }

    @Autowired
    protected MemVerificationCache cache;


    @ApiOperation(value = "客户钱包")
    @PostMapping
    public StatusResponse get(String areaId, String clientId){
        Clientele c = clienteleService.getById(areaId, clientId);

        if (c == null){
            throw new BusinessException(ErrorCode.CLIENTELE_EXIST, "客户不存在");
        }

        Wallet w = baseService.queryWalletByClientele(c);

        return StatusResponse.success(w);
    }
}
